package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.StrategyComment;
import cn.wolfcode.wolf2w.query.StrategyCommentQuery;
import cn.wolfcode.wolf2w.service.IStrategyCommentService;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("strategyComment")
public class StrategyCommentController {
    
    @Autowired
    private IStrategyCommentService strategyCommentService;

    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo") StrategyCommentQuery qo){

        Page<StrategyComment> page = strategyCommentService.query(qo);
        model.addAttribute("page",page);
        return "strategyComment/list";
    }

    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(String id){
        strategyCommentService.delete(id);
        return JsonResult.success();
    }

    /*@RequestMapping("input")
    public Object Input(Model model,String id){

        model.addAttribute("catalogs",strategyCatalogService.queryStrategyCatalogGroupByDestName());
        model.addAttribute("themes",strategyThemeService.list());
        if (StringUtils.hasLength(id)){
            model.addAttribute("strategyComment",strategyCommentService.get(id));
        }
        return "strategyComment/input";
    }*/

    @RequestMapping("saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(StrategyComment strategyComment){
        strategyCommentService.saveOrUpdate(strategyComment);
        return JsonResult.success();
    }
}
